//
//  FZ_TuiJian_TableViewCell_One.m
//  ProjectOfBStage
//
//  Created by dllo on 15/11/13.
//  Copyright © 2015年 cuixin. All rights reserved.
//

#import "FZ_TuiJian_TableViewCell_One.h"
#import "FZ_TuiJian_CollectionViewCell.h"
#import "FZ_BoFang_One_ViewController.h"
#import "FZ_RootModelR.h"
@interface FZ_TuiJian_TableViewCell_One ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
@property (nonatomic ,retain) UICollectionView *collectionViewOne;
@end
@implementation FZ_TuiJian_TableViewCell_One
- (void)dealloc
{
    [_arrayJieShou release];
    [_jieShouModel release];
    [_collectionViewOne release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//        _arrayJieShou = [NSMutableArray array];
        [self createSubviews];
        
    }
    return self;
}

- (void)createSubviews{
    
    UICollectionViewFlowLayout *flowLayoutOne = [[UICollectionViewFlowLayout alloc] init];
    
#pragma bounds 问题
    self.collectionViewOne = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 400.f) collectionViewLayout:flowLayoutOne];
    self.collectionViewOne.delegate = self;
    self.collectionViewOne.dataSource = self;
    self.collectionViewOne.bounces = NO;
    self.collectionViewOne.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.collectionViewOne];
    [self.collectionViewOne release];
    
    UINib *nibFZ_TuiJianCell_One = [UINib nibWithNibName:@"FZ_TuiJian_CollectionViewCell" bundle:[NSBundle mainBundle]];
    [self.collectionViewOne registerNib:nibFZ_TuiJianCell_One forCellWithReuseIdentifier:@"FZ_TuiJianCell"];
    [_collectionViewOne reloadData];


}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(172.f, 213.f);
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    
    return UIEdgeInsetsMake(10, 10, 0, 10);
    
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
        if (0 != self.arrayJieShou.count) {
            return self.arrayJieShou.count;
        }
    return 4;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    FZ_TuiJian_CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FZ_TuiJianCell" forIndexPath:indexPath];
    FZ_RootModelR *model = self.arrayJieShou[indexPath.row];
    cell.jieShouModelF = model;
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    FZ_RootModelR *model = self.arrayJieShou[indexPath.row];
    [self.delegate collectionCellToBoFangXQ:nil andModel:model];
}


+ (FZ_TuiJian_TableViewCell_One *)presentTabelViewCell:(UITableView *)tabelView
{
    
    static NSString *cellIndetf = @"FZ_TuiJian_TableViewCell_One";
    
    FZ_TuiJian_TableViewCell_One *cell = [tabelView dequeueReusableCellWithIdentifier:cellIndetf];
    
    if (cell == nil) {
        
        cell = [[FZ_TuiJian_TableViewCell_One alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndetf];
    }
    
    return cell;
    
}

- (void)ReloadData{
    [self.collectionViewOne reloadData];
}

- (void)setJieShouModel:(FZ_RootModelR *)jieShouModel{
    if (_jieShouModel != jieShouModel) {
        [_jieShouModel release];
        _jieShouModel = [jieShouModel retain];
        [self.collectionViewOne reloadData];
    }

    [self.collectionViewOne reloadData];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
